<template>
	<view class="page-con">
		<view class="u-p-10">
			<u-swiper :list="bannerList" @click="handleClickSwiper($event)" height="300" mode="round" indicator-pos="topRight"
				img-mode="aspectFill">
			</u-swiper>
		</view>
		<view class="u-p-10">
			<u-notice-bar mode="horizontal" :font-size="notice_font_size" :speed="notice_speed" :list="noticeList"
				@click="handleClickNotice"></u-notice-bar>

		</view>
		<view class="tab-box u-flex ">
			<view class="u-flex tab-item  u-text-center u-b-r-20" v-for="(item,index) in lifeList" :key="index"
				@click="lifeClick(item)" :class="lifeType==item.type?'tab-active cl_FFF':'cl_FFF'">
				<u-icon size="50" :name="item.icon"></u-icon>
				<view class="tab-text">
					{{item.name}}
				</view>
			</view>
		</view>
		<view class="one1">
			<view class="u-p-20 u-m-t-20 u-b-r-20 bg_FFFFFF">
				<view class="u-m-t-20 choes-box" v-if="list.length">
					<u-row>
						<u-col span='4' v-for="(item,index) in list " :key="index">
							<view class="u-m-t-20 u-text-center custom-choose" @click="choes(item)"
								:class="num==item.id?'choes':'choes1'">
								<view class="total_money">
									¥{{item.total_money}}
								</view>
								<view class="current">
									抵扣：{{dcScoreList.deduct_amount}}元
									<!-- ¥{{dcScoreList.pay_money}}+{{dcScoreList.deduct_amount}}抵扣金 -->
								</view>
							</view>
						</u-col>
					</u-row>
				</view>

				<view class="u-m-t-20 u-flex u-row-between u-font-28 cl_FB473CFF">
					<view class="">
						可用抵扣金: {{dcScoreList.deduct||'0'}}元
					</view>
					<view class="">
						本次抵扣: {{dcScoreList.deduct_amount}}
					</view>
				</view>
				<view class="u-flex u-row-between u-m-t-20">
					<view class="u-weight"></view>
					<view class="u-font-32 u-weight u-text-right"
						@click="$u.route(`/subcontract/Rechargemoney2/massage2/massage2?type=${lifeType}&is_new=1`)">
						充值记录 <u-icon class="u-m-l-5" name="arrow-right"></u-icon>
					</view>
				</view>
			</view>
			<view class="u-p-l-20 u-p-r-20 bg_FFFFFF form-box">
				<!-- 电费 --><!-- 水费 -->
				<view class="u-font-28" v-if="lifeType==3||lifeType==4">
					<view class="" style="display: flex;align-items: center;padding-left: 10px;">
						<u-input v-model="elec_no" type="number" placeholder='请输入户号' style="flex:1"></u-input>
						<u-button type="primary" size="mini" @click="handlePasteElecNo">粘贴</u-button>
						<u-button style="margin-left: 5px;" type="primary" size="mini" @click="handleGetView">查看获取方式</u-button>
					</view>
					<view class="" style="display: flex;align-items: center;padding-left: 10px;">
						<u-input v-model="elec_name" placeholder='请输入姓名' style="flex:1"></u-input>
						<u-button type="primary" size="mini" @click="handlePasteElecName">粘贴</u-button>

					</view>

				</view>
				<!-- 燃气 -->
				<view class="u-font-28" v-if="lifeType==2">
					<view class="" style="display: flex;align-items: center;padding-left: 10px;">
						<u-input type="number" v-model="gas_no" placeholder='请输入户号' style="flex:1"></u-input>
						<u-button type="primary" size="mini" @click="handlePasteGas">粘贴</u-button>
						<u-button style="margin-left: 5px;" type="primary" size="mini" @click="handleGetView">查看获取方式</u-button>
					</view>
					<view class="" style="display: flex;align-items: center;padding-left: 10px;">
						<u-input v-model="elec_name" placeholder='请输入姓名' style="flex:1"></u-input>
						<u-button type="primary" size="mini" @click="handlePasteElecName">粘贴</u-button>

					</view>



				</view>
				<view class="u-w-300" style="padding-left: 10px;">
					<u-input v-model="area_name" disabled @click="cityShow=true" placeholder='请选择省份'></u-input>
				</view>
			</view>

			<view class="form-box">
				<view class="title-header u-flex u-row-between">
					<view class="title-text">待付款链接:</view>
					<u-button type="primary" size="mini" @click="handleGetView2">获取方法</u-button>
				</view>
				<view class="title-header u-flex u-row-between">
					<u-input type="textarea" v-model="paymentLink" placeholder='请输入或者粘贴链接' style="flex:1"></u-input>
					<u-button type="primary" size="mini" @click="handlePastePaymentLink">粘贴</u-button>
				</view>
				<view class="" style="color: #9a9695; text-align: center;">
					此处粘贴去掉文字的纯链接
				</view>
			</view>
			<view class="u-flex" style="justify-content: center;color: #545253;padding: 0 20rpx;" v-if="currentDetail">
				{{currentDetail.link.notice}}
			</view>

			<!-- 支付方式 -->
			<view class=" one1 u-p-t-20">
				<view class="u-flex-col u-col-center">- 支付方式 -</view>
			</view>
			<!-- 支付类型 -->
			<view class="one1 u-p-30">
				<view class="bg_FFFFFF u-b-r-20">
					<view @click="pays='deposit'" class="u-flex u-row-between u-p-30"
						style="border-bottom: 1rpx solid #F6F6F6FF;">
						<view class="u-flex">
							<view class=" u-flex">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/card.png" mode="aspectFill" width="50rpx"
									height='50rpx'>
								</u-image>
								<view class="u-m-l-30 u-font-28 u-weight">钱包支付</view>
							</view>
							<view class="u-m-l-30">
								<view class=" cl_898989FF u-font-24">余额<text class="cl_FB473CFF">￥{{userinfo.user_wallet}}</text></view>
							</view>
						</view>
						<view class="u-flex">
							<view class="">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c1.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-if="pays=='deposit'"></u-image>
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-else></u-image>
							</view>
						</view>
					</view>

					<view style="color: #afacac;font-size: 26rpx;padding: 14rpx;">请充值余额并优先选择余额支付</view>

					<view @click="openEpayDialog" class="u-flex u-row-between u-p-30"
						style="border-bottom: 1rpx solid #F6F6F6FF;">
						<view class="">
							<view class=" u-flex">
								<u-image src="http://xcx.itcwc.com/wxImg/5dcf4786109a5.png" mode="aspectFill" width="50rpx"
									height='50rpx'>
								</u-image>
								<view class="u-m-l-30 u-font-28 u-weight">易支付</view>
							</view>

						</view>
						<view class="u-flex">
							<!-- <view class="u-m-r-20 cl_FB473CFF">-￥{{userinfo.goods_amount}}</view> -->
							<view class="">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c1.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-if="pays == 'epay'"></u-image>
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-else>
								</u-image>
							</view>
						</view>
					</view>


					<!-- #ifndef H5  -->
					<view v-if="showWechatPay && is_wechat_switch == 1" @click="pays='wechat'" class="u-flex u-row-between u-p-30"
						style="border-bottom: 1rpx solid #F6F6F6FF;">
						<view class="">
							<view class=" u-flex">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/wx.png" mode="aspectFill" width="50rpx"
									height='50rpx'>
								</u-image>
								<view class="u-m-l-30 u-font-28 u-weight">微信支付</view>
							</view>
						</view>
						<view class="u-flex">
							<view class="">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c1.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-if="pays=='wechat'"></u-image>
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-else></u-image>
							</view>
						</view>
					</view>
					<!-- #endif -->
					<!-- #ifdef APP-PLUS -->

					<view v-if="!isWechatMP && userinfo.alipay_switch==1" @click="pays='alipay'"
						class="u-flex u-row-between u-p-30" style="border-bottom: 1rpx solid #F6F6F6FF;">
						<view class="">
							<view class=" u-flex">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/zf.png" mode="aspectFill" width="50rpx"
									height='50rpx'>
								</u-image>
								<view class="u-m-l-30 u-font-28 u-weight">支付宝支付</view>
							</view>

						</view>
						<view class="u-flex">
							<view class="">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c1.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-if="pays=='alipay'"></u-image>
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/c.png" mode="aspectFill" width="30rpx"
									height='30rpx' v-else></u-image>
							</view>
						</view>
					</view>
					<!-- #endif -->
				</view>
			</view>


			<view class="parse-box u-p-20 bg_FFFFFF">
				<view class="u-flex u-row-between">
					<view class="title-text"></view>
					<u-read-more :isShowMore="isShowMore" show-height="200" toggle ref="uReadMore" @open="handleOpenRead"
						@close="handleCloseRead">
						<view class="u-m-t-20" style="overflow-x: hidden;">
							<u-parse :html="remark"></u-parse>
						</view>
					</u-read-more>
				</view>
				<view style="overflow-x: hidden;">

				</view>

			</view>

			<view class="footer">

				<view class="u-w-700 u-auto u-text-center" style="margin-top: 15px;">
					<u-checkbox v-model="confirmed">我已阅读充值说明</u-checkbox>
				</view>
				<view class="u-w-700 u-auto u-h-80 u-l-h-80 u-text-center u-b-r-13 cl_FFF"
					style="background: linear-gradient(-64deg, #FF382C, #FF633F);" @click="save">提交支付</view>
			</view>


			<u-toast ref="uToast" />
			<u-select v-model="cityShow" mode="mutil-column-auto" child-name="child" value-name="id" label-name="area_name"
				:list="address_list" @confirm="cityFirm"></u-select>
			<u-select v-model="show1" :list="companyList" @confirm="handleGetCompany"></u-select>
			<u-popup v-model="shows" mode='center'>
				<view class="u-p-30 u-h-200">
					<u-message-input :focus="true" :maxlength='6' @finish="finish"></u-message-input>
				</view>
			</u-popup>
			<!-- 易支付选择弹窗 -->
			<u-popup v-model="showEpayDialog" mode="center" width="80%" border-radius="10">
				<view class="epay-dialog">
					<view class="epay-dialog-title">请选择支付方式</view>
					<view class="epay-dialog-content">
						<view class="epay-payment-option" @click="selectEpayMethod('wxpay')">
							<view class="radio-button">
								<view class="radio-inner" :class="{ 'radio-selected': params.epay_type === 'wxpay' }"></view>
							</view>
							<view class="payment-icon">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/wx.png" mode="aspectFill" width="40rpx"
									height='40rpx'></u-image>
							</view>
							<view class="payment-name">微信支付</view>
						</view>
						<view v-if="!isWechatMP" class="epay-payment-option" @click="selectEpayMethod('alipay')">
							<view class="radio-button">
								<view class="radio-inner" :class="{ 'radio-selected': params.epay_type === 'alipay' }"></view>
							</view>
							<view class="payment-icon">
								<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/zf.png" mode="aspectFill" width="40rpx"
									height='40rpx'></u-image>
							</view>
							<view class="payment-name">支付宝支付</view>
						</view>
					</view>
					<view class="epay-dialog-footer">
						<view class="epay-dialog-btn cancel-btn" @click="showEpayDialog = false">取消</view>
						<view class="epay-dialog-btn confirm-btn" @click="confirmEpayMethod">确定</view>
					</view>
				</view>
			</u-popup>
			<!-- 充值须知 -->
			<u-popup v-model="show" mode='center'>
				<view class="u-rela u-p-50 u-w-700 ">
					<view class="u-font-50 u-weight">充值须知</view>

					<view class="u-fix u-r-60 u-t-300">
						<u-image src="https://www.sqkjkj.vip/wxImg/common/sign/heart.png" mode="aspectFill" width="216rpx"
							height='274rpx'>
						</u-image>
					</view>

					<view @click="show=false"
						class="u-m-t-20 u-w-400 u-h-92 u-l-h-92 u-font-30 u-text-center u-auto cl_FFF u-b-r-20"
						style="background-color: #FC3533FF;">我知道了</view>

				</view>

			</u-popup>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			show1: false,
			// 选择充值金额
			num: '',
			// 充值须知弹窗
			show: false,
			// 充值方式
			pays: 'wechat',
			// 可用积分
			pays1: "",
			// 充值选项
			list: [],
			// 充值金额
			pay_money: 0,
			userinfo: '',
			shows: false,
			pays_list: '',
			dcScoreList: '',
			lifeType: '3',
			lifeList: [],
			gas_no: '', //燃气号
			elec_no: '', //户号
			elec_name: '', // 户名
			area_name: '', //区域
			area_id: '', //区域
			cityShow: false,
			address_list: [],
			conf: [],
			confirmed: false,
			innerAudioContext: null,

			buttomAdInfo: null,
			bannerList: [],
			noticeList: [],
			remark: '',
			paymentLink: '',
			notice_font_size: 26,
			notice_speed: 160,
			isShowMore: true,
			showWechatPay: true,
			showEpayDialog: false,
			params: {
				epay_type: 'wxpay',
				method: '',
			},
			isWechatMP: false,
			is_wechat_switch: '1',
			is_alipay_switch: '1',
		}
	},
	computed: {
		currentDetail() {
			const data = this.lifeList.filter(i => i.type == this.lifeType)
			if (data.length) {
				return data[0]
			}
			return null
		}
	},
	onLoad(options) {
		this.is_wechat_switch = options.is_wechat_switch
		this.is_alipay_switch = options.is_alipay_switch
		if (uni.getStorageSync('isOpen') == 0) {
			this.isShowMore = false
		} else {
			this.isShowMore = true
		}
		this.getbanner()
		this.apply_join()
		this.lifeRechargeType()
		this.getHoldingRemark()
		this.userinfo = uni.getStorageSync("userinfo")
		this.wechatPaySwitch()
		this.detectDeviceType()
	},

	onShow() {
		if (uni.getStorageSync('gas_no')) {
			this.gas_no = uni.getStorageSync('gas_no')
		}
		if (uni.getStorageSync('elec_no')) {
			this.elec_no = uni.getStorageSync('elec_no')
		}

	},
	methods: {
		wechatPaySwitch() {
			this.$api.wechatPaySwitch({}, (res) => {

				// #ifdef MP-WEIXIN
				if (res.data.data.mini != 1) {
					this.pays = 'deposit'
					this.showWechatPay = false
				}
				//  #endif
				// #ifdef APP-PLUS
				if (res.data.data.mini != 1) {
					this.pays = 'alipay'
					this.showWechatPay = false
				}
				// #endif
				// #ifdef H5
				if (res.data.data.mini != 1) {
					this.pays = 'deposit'
				}
				// #endif
			})
		},
		// 省份列表
		apply_join() {
			this.$api.apply_join({
				level: "2"
			}, res => {
				this.address_list = res.data.data
			})
		},
		cityFirm(e) {
			this.area_name = `${e[0].label}${e[1].label}`
			this.area_id = e[1].value
		},
		getHoldingRemark() {
			this.$api.getHoldingRemark({}, (res) => {
				this.remark = res.data.data.remark
				console.log(res)
				this.notice_font_size = res.data.data.notice_font_size
				this.notice_speed = res.data.data.notice_speed
				this.$nextTick(() => {
					this.$refs.uReadMore.init();
				})
			})
		},
		handleOpenRead() {
			uni.setStorageSync('isOpen', 1)
			console.log('打开')
		},
		handleCloseRead() {
			uni.setStorageSync('isOpen', 0)
		},
		handleClickNotice(item) {
			console.log(item)
		},
		customUrl(c) {
			if (c.url_type == 'goods_detail') {
				this.$u.route(`/pages/home/paymassage?num=${c.params.spu}`)
			} else if (c.url_type == 'goods_list') {
				this.$u.route({
					type: 'switchTab',
					url: '/pages/home/home'
				})
			} else if (c.url_type == 'shop_detail') {
				this.$u.route(`/pages/shopmassage/shopmassage?num=${c.params.shop_id}`)
			} else if (c.url_type == 'announce_detail') {
				this.$u.route(`/subcontract/mymassage/systemMessages/detail?announce_id=${c.params.announce_id}`)
			}
		},
		getbanner() {
			this.$api.getliveBanner({}, (res) => {
				res.data.data.banner.forEach(img => {
					img.image = img.pic
				})
				this.bannerList = res.data.data.banner
				this.noticeList = res.data.data.notice.map(i => i.content)

			})
		},
		handleGetView() {
			// const data = this.lifeList.filter(i => i.type == this.lifeType)[0]
			this.customUrl(this.currentDetail.link)
			// lifeList
		},
		handleGetView2() {
			this.customUrl(this.currentDetail.link2)
		},
		handleClickSwiper(item) {
			this.customUrl(this.bannerList[item])
			// console.log()
		},
		handlePasteGas() {
			uni.getClipboardData({
				success: (res) => {
					this.gas_no = res.data
				}
			})
		},
		handlePasteElecName() {
			uni.getClipboardData({
				success: (res) => {
					this.elec_name = res.data
				},
				fail: (err) => {
					console.log(err)
				}
			})
		},
		handlePastePaymentLink() {
			uni.getClipboardData({
				success: (res) => {
					this.paymentLink = res.data
				}
			})
		},
		handlePasteElecNo() {
			uni.getClipboardData({
				success: (res) => {
					this.elec_no = res.data
				}
			})
		},
		backs() {
			uni.navigateBack()
		},
		lifeRechargeType() {
			this.$api.lifeRechargeType2({
				is_new: 1
			}, res => {
				if (res.data.code == 1) {
					this.lifeList = res.data.data
					this.massage()
				}
			})
		},
		lifeClick(item) {
			this.lifeType = item.type
			this.massage()
		},
		massage() {
			this.num = ''
			this.$api.choes_my_phone2({
				type: this.lifeType,
				is_new: 1
			}, res => {
				if (res.data.code == 1) {
					this.list = res.data.data.money_list
					if (this.list.length > 0) {
						this.num = this.list[0].id
						this.getDcScore()
					}
				}
			})
		},
		getDcScore() {
			this.$api.getDcScore2({
				type: this.lifeType,
				recharge_money_id: this.num,
				is_new: 1
			}, res => {
				if (res.data.code == 1) {
					this.dcScoreList = res.data.data
				}
			})
		},
		choes(item) {
			this.num = item.id
			this.pay_money = item.pay_money
			this.getDcScore()
		},
		save() {
			console.log(this.num)
			if (!this.confirmed) {
				uni.showToast({
					icon: 'none',
					title: '请阅读充值说明'
				})
				return
			}
			if (this.num == 0 || this.num == '') {
				uni.showToast({
					icon: 'none',
					title: '请选择充值金额'
				})
			} else if (this.pays == '') {
				uni.showToast({
					icon: 'none',
					title: '请选择支付方式'
				})
			} else {
				let params = {}
				if (this.lifeType == 2) {
					if (!this.elec_name) {
						uni.showToast({
							icon: 'none',
							title: '请输入姓名'
						})
						return
					}
					if (this.gas_no == '') {
						uni.showToast({
							icon: 'none',
							title: '请输入户号'
						})
						return
					}
					// console.log(/^\d+$/.test(this.gas_no))
					if (!/^\d+$/.test(this.gas_no)) {
						uni.showToast({
							icon: 'none',
							title: '户号只能输入数字'
						})
						return
					}
					params = {
						elec_name: this.elec_name,
						gas_no: this.gas_no,

					}
					uni.setStorageSync('gas_no', this.gas_no)
				}
				if (this.lifeType == 3 || this.lifeType == 4) {
					if (!this.elec_name) {
						uni.showToast({
							icon: 'none',
							title: '请输入姓名'
						})
						return
					}
					if (this.elec_no == '') {
						uni.showToast({
							icon: 'none',
							title: '请输入电费户号'
						})
						return
					}
					if (!/^\d+$/.test(this.elec_no)) {
						uni.showToast({
							icon: 'none',
							title: '户号只能输入数字'
						})
						return
					}
					params = {
						elec_no: this.elec_no,
						elec_name: this.elec_name,
					}
					uni.setStorageSync('elec_no', this.elec_no)
				}
				// if (this.area_id == '') {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '请选择省份'
				// 	})
				// 	return
				// }
				if (!this.paymentLink) {
					uni.showToast({
						icon: 'none',
						title: '请输入待付款链接'
					})
					return
				}
				if (this.paymentLink) {
					params.link = this.paymentLink
				}
				params = Object.assign({
					type: this.lifeType,
					money_id: this.num,
					area_id: this.area_id,
					is_new: 1,

				}, params)
				this.$api.pay_my_phone2(params, res => {
					if (res.data.code == 1) {
						this.pays_list = res.data.data.pay_info
						if (this.pays == 'deposit') {
							// if (uni.getStorageSync('userinfo').have_trade_pwd == 0) {
							// 	uni.showModal({
							// 		title: '提示',
							// 		content: '请先设置余额支付密码',
							// 		success: (res) => {
							// 			if (res.confirm) {
							// 				this.$u.route(
							// 					'/pages/changePayPassword/changePayPassword')
							// 			} else {

							// 			}
							// 		}
							// 	})
							// 	return
							// }
							// this.shows = true
							this.pay();
						}

						if (this.pays == 'epay') {
							this.pay();
							return
						}

						if (this.pays == "wechat" || this.pays == 'alipay') {
							let params = {
								target_id: this.pays_list.target_id,
								target_type: this.pays_list.target_type,
								pay_type: this.pays,
								is_new: 1,
								// #ifdef APP-PLUS
								client: 'APP',
								// #endif
								// #ifdef MP-WEIXIN
								client: 'JSAPI',
								// #endif
								trade_pwd: '',
								random: 1
							}
							// #ifdef APP-PLUS
							this.$com.wxPay2(params, this.pays).then(ok => {
								console.log(ok)
								this.$refs.uToast.show({
									title: ok.data.msg,
									type: 'success',
									callback: cal => {

										this.paySucess(ok.data.data.actual_money)
									}
								})
							})
							// #endif
							// #ifdef MP-WEIXIN
							this.$com.weChatPay2(params, this.pays).then(ok => {
								console.log(ok)
								this.$refs.uToast.show({
									title: ok.msg,
									type: 'success',
									callback: cal => {

										this.paySucess(ok.data.actual_money)
									}
								})
							})
							// #endif
						}
					}
				})
			}
		},

		finish(e) {
			console.log('输入结束，当前值为：' + e);
			this.pay(e)
			this.shows = false
		},
		paySucess(pay_money) {
			let goodsName = ''
			let payType = ''
			if (this.lifeType == 4) {
				goodsName = '充值水费'
			}
			if (this.lifeType == 2) {
				goodsName = '充值燃气费'
			}
			if (this.lifeType == 3) {
				goodsName = '充值电费'
			}
			if (this.pays == 'alipay') {
				payType = '支付宝'
			}
			if (this.pays == 'wechat') {
				payType = '微信'
			}
			if (this.pays == 'deposit') {
				payType = '钱包余额'
			}
			if (this.pays == 'epay') {
				payType = '易支付'
				// uni.navigateBack();
				// uni.navigateTo({
				// 	url: '/pages/webview/webview?url=' + encodeURIComponent(`http://xcx.itcwc.com/subcontract/payStatus/payStatus?goodsName=${goodsName}&payType=${payType}&payMoney=${pay_money}`)
				// });
				// return;
			}
			
			const payMoney = this.dcScoreList.pay_money
			const base_url = 'http://xcx.itcwc.com/member/#/'

			// #ifdef APP-PLUS
			
				this.$u.route({
					type: 'reLaunch',
					url: `/subcontract/payStatus/payStatus?goodsName=${goodsName}&payType=${payType}&payMoney=${payMoney}`
				})
			// #endif
			// #ifdef H5
			this.$u.route({
				type: 'reLaunch',
				url: `/subcontract/payStatus/payStatus?goodsName=${goodsName}&payType=${payType}&payMoney=${payMoney}`
			})
			// #endif
			// this.$u.route({
			// 	type: 'reLaunch',
			// 	url: `/subcontract/payStatus/payStatus?goodsName=${goodsName}&payType=${payType}&payMoney=${pay_money}`
			// })
		},
		pay(e = '') {
			if (this.pays == 'epay') {
				// 易支付
				let params = {
					target_id: this.pays_list.target_id,
					target_type: this.pays_list.target_type,
					pay_type: this.pays,
					// 如果是微信小程序，强制使用微信支付
					type: this.isWechatMP ? 'wxpay' : this.params.epay_type,
					method: this.params.method,
					client: 'APP',
					trade_pwd: e,
					random: 1,
					// 根据不同平台设置不同的client参数
					// #ifdef APP-PLUS
					client: 'APP',
					// #endif
					// #ifdef MP-WEIXIN || MP-ALIPAY
					client: 'JSAPI',
					// #endif
					// #ifdef H5
					client: 'WAP',
					// #endif
				}
				this.$com.easyPay(params, this.pays);
			} else {
				uni.showLoading({
					title: '支付中',
					mask: true
				});
				this.$api.go_pay2({
					target_id: this.pays_list.target_id,
					target_type: this.pays_list.target_type,
					pay_type: this.pays,
					type: this.isWechatMP ? 'wxpay' : this.params.epay_type,
					method: this.params.method,
					client: 'APP',
					trade_pwd: e,
					random: 1
				}, res => {
					uni.hideLoading();
					if (res.data.code == 0) {
						uni.showToast({
							icon: 'none',
							title: '充值成功'
						})

					} else {
						uni.showToast({
							icon: 'none',
							title: res.data.msg
						})
					}
				})
			}

		},

		// 调取微信
		wxpay(obj) {
			uni.showToast({
				icon: 'none',
				title: '暂时仅支持余额'
			})
		},
		openEpayDialog() {
			this.pays = 'epay'
			// 在微信小程序环境中，默认选择微信支付
			if (this.isWechatMP) {
				this.params.epay_type = 'wxpay'
			}
			this.showEpayDialog = true
		},
		selectEpayMethod(type) {
			// 如果是微信小程序环境且尝试选择支付宝支付，则不允许
			if (this.isWechatMP && type === 'alipay') {
				return
			}
			this.params.epay_type = type
		},
		confirmEpayMethod() {
			this.showEpayDialog = false
		},
		detectDeviceType() {
			// #ifdef H5
			this.params.method = 'web' // H5环境使用web
			this.isWechatMP = false
			// #endif

			// #ifdef MP-WEIXIN
			this.params.method = 'jsapi' // 微信小程序环境使用jsapi
			this.isWechatMP = true
			// #endif

			// #ifdef MP-ALIPAY
			this.params.method = 'jsapi' // 支付宝小程序环境使用jsapi
			this.isWechatMP = false
			// #endif

			// #ifdef APP-PLUS
			this.params.method = 'web' // APP环境使用app
			this.isWechatMP = false
			// #endif

			console.log('当前设备类型:', this.params.method)
			console.log('是否为微信小程序:', this.isWechatMP)
		}
	}
}
</script>

<style scoped lang="scss">
page {
	background-color: #f5f5f5;

}

.page-con {
	padding-bottom: 150px;
}

.footer {
	position: fixed;
	width: 100vw;
	left: 0;
	bottom: 0;
	background-color: #ffffff;
	height: 120px;
	padding: 10px 0;
	z-index: 100;
}

.one1 {
	background-color: #f5f5f5;

	.error {
		font-size: 24rpx;
		color: red;
	}
}

.tab-box {
	margin: 0 10px;
	padding: 15px 10px;
	background-color: #fdc254;
	border-radius: 15px;
	box-shadow: 0 0 10px #000;
}

.tab-item {
	padding: 20px 0;
	justify-content: center;
	background-color: #88c1fe;
	width: 210rpx;
	margin: 0 5px;
	font-size: 40rpx;
}

.tab-active {
	background-color: #1d00fe;
}

.tab-text {
	margin-left: 2px;
}

.choes-box {
	box-shadow: 0 0 10px #000;
	background-color: #fdc254;
	padding: 10px 10px;
	border-radius: 15px;
}

.form-box {
	padding: 20px 0;
	margin: 20px 10px;
	box-shadow: 0 0 4px #000;
}

.title-header {
	padding: 0 10px;
}

.title-text {
	color: #9a9695;
}

.parse-box {
	padding: 20px 0;
	margin: 20px 10px;
	box-shadow: 0 0 4px #000;
}

.up-or-dwn {
	color: #2979ff;
}

.choes {
	background-color: #35ff07;
	color: #545253;
	font-weight: bold;

	.current {
		font-size: 10px;
		display: inherit;
		color: #f10007;
	}

}

.form-box {}



.choes1 {
	background-color: #ffffff;
	color: #545253;


	.current {
		font-size: 10px;
		display: inherit;
		color: #f10007;
		display: none;
	}
}

.custom-choose {
	height: 80px;

	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	border-radius: 10px;
}

/* 易支付选择弹窗样式 */
.epay-dialog {
	background-color: #fff;
	padding: 30rpx;
}

.epay-dialog-title {
	font-size: 32rpx;
	font-weight: bold;
	text-align: center;
	margin-bottom: 30rpx;
}

.epay-dialog-content {
	padding: 20rpx 0;
}

.epay-payment-option {
	display: flex;
	align-items: center;
	padding: 20rpx 0;
	border-bottom: 1rpx solid #f5f5f5;
}

.radio-button {
	width: 36rpx;
	height: 36rpx;
	border-radius: 50%;
	border: 2rpx solid #ddd;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 20rpx;
}

.radio-inner {
	width: 20rpx;
	height: 20rpx;
	border-radius: 50%;
	background-color: transparent;
}

.radio-selected {
	background-color: #3298FD;
}

.payment-icon {
	margin-right: 20rpx;
}

.payment-name {
	font-size: 28rpx;
}

.epay-dialog-footer {
	display: flex;
	justify-content: space-between;
	margin-top: 40rpx;
}

.epay-dialog-btn {
	width: 45%;
	height: 80rpx;
	border-radius: 40rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28rpx;
}

.cancel-btn {
	background-color: #f5f5f5;
	color: #666;
}

.confirm-btn {
	background-color: #3298FD;
	color: #fff;
}
</style>